﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;
using ClassLibrary.Entity;

namespace ClassLibrary.DAO
{
    public class TblNoiDungLaiXeThuDAO
    {
        private DBService _db = null;
        public TblNoiDungLaiXeThuDAO(String ConnectionString)
        {
            _db = new DBService(ConnectionString);
        }

        public DataTable Ins_NoiDungLaiThuXe(TblNoiDungLaiThuXe ndlaithuxe, int mode)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("sp_TblNoiDungLaiThuXe_InsUp",
                    new string[] {"@ID", "@TieuDe", "@NoiDung", "@Mode" }, new object[] { ndlaithuxe.ID, ndlaithuxe.TieuDe, ndlaithuxe.NoiDung, mode }, CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetALL()
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblNoiDungLaiThuXe", false, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }
        public DataTable GetNoiDung_ByID(int ID)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblNoiDungLaiThuXe where ID = @ID", new string[] {"@ID" }, new object[]{ ID }, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

    }
}
